package com.hnkywl.sts.action.sys;

import com.hnkywl.sts.service.sys.DsgdService;
import com.hnkywl.sts.service.taskdeal.DoBgcgdSync;
import com.hnkywl.sts.service.taskdeal.DoBgwzbmSync;
import com.hnkywl.sts.service.taskdeal.DoGdImport;
import com.hnkywl.sts.service.taskdeal.DoPlanImport;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 手动执行定时服务
 * User: ccr
 * Date: 13-9-16
 * Time: 下午2:34
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/sys/quartz")
public class QuartzAction extends SimpleActionSupport {
    private DoBgcgdSync doBgcgdSync;
    private DoBgwzbmSync doBgwzbmSync;
    private DoPlanImport doPlanImport;
    private DoGdImport doGdImport;
    private DsgdService dsgdService;
    private String hours;
    private String minutes;
    private String seconds;
    private String ids;
    private List<Long> gsIds;

    //判断页面跳转
    @Action("quartz")
    public String quartz() {
        gsIds = dsgdService.findDsgdGsIds();
        return SUCCESS;
    }

    //保供采购单同步接口执行
    @Action("doBgcgdSync")
    public void doBgcgdSync() {
        try {
            doBgcgdSync.doBgcgdSync();
            renderJson("{\"statusCode\":200}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\"300,\"message\":\"" + e.getMessage() + "\"}");
        }
    }

    //保供采购单同步接口执行
    @Action("doBgwzbmSync")
    public void doBgwzbmSync() {
        try {
            doBgwzbmSync.doBgwzbmSync();
            renderJson("{\"statusCode\":200}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\"300,\"message\":\"" + e.getMessage() + "\"}");
        }
    }

    //保供采购单同步接口执行
    @Action("doPlanImport")
    public void doPlanImport() {
        try {
            doPlanImport.importPlan();
            renderJson("{\"statusCode\":200}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\"300,\"message\":\"" + e.getMessage() + "\"}");
        }
    }

 /*   @Action("doGdImport")
    public void doGdImport() {
        try {
            doGdImport.handleTestJob(ids, hours, minutes, seconds);
            renderJson("{\"statusCode\":200}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\"300,\"message\":\"" + e.getMessage() + "\"}");
        }
    }*/

    public String getIds() {
        return ids;
    }

    public void setIds(String ids) {
        this.ids = ids;
    }

    public String getHours() {
        return hours;
    }

    public void setHours(String hours) {
        this.hours = hours;
    }

    public String getMinutes() {
        return minutes;
    }

    public void setMinutes(String minutes) {
        this.minutes = minutes;
    }

    public String getSeconds() {
        return seconds;
    }

    public void setSeconds(String seconds) {
        this.seconds = seconds;
    }

    public List<Long> getGsIds() {
        return gsIds;
    }

    public void setGsIds(List<Long> gsIds) {
        this.gsIds = gsIds;
    }

    @Autowired
    public void setDoBgcgdSync(DoBgcgdSync doBgcgdSync) {
        this.doBgcgdSync = doBgcgdSync;
    }

    @Autowired
    public void setDoBgwzbmSync(DoBgwzbmSync doBgwzbmSync) {
        this.doBgwzbmSync = doBgwzbmSync;
    }

    @Autowired
    public void setDoPlanImport(DoPlanImport doPlanImport) {
        this.doPlanImport = doPlanImport;
    }

   /* @Autowired
    public void setDoGdImport(DoGdImport doGdImport) {
        this.doGdImport = doGdImport;
    }*/

    @Autowired
    public void setDsgdService(DsgdService dsgdService) {
        this.dsgdService = dsgdService;
    }
}
